<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <title>${title}</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
   <%--  <link rel="stylesheet" href="${basePath}/static/css/content_leftNav.css"/>
    <link rel="stylesheet" href="${basePath}/static/css/FrontControl.css"/>
     --%>
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
	<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
	<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/qualityNav.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0">查询病案进行质控评分</h3>
        </div>
        <div class="list_con_table">
           <div class="search_table">
            <input type="hidden" id="qualityStatus" value="${medicalSearchVO.qualityStatus}">
                <ul class="clearfix" style="margin-bottom:0;">
                            <li class="Label_1" style="width:11%">出院日期：&nbsp;</li>
               <li class="Label_2" style="width:27%;">
                   <input style="width:43%;" class="input_box" id="outHospitalStartDate" value='${startTime}' onFocus="WdatePicker()" type="text" > 
                   - <input style="width:43%" class="input_box" id="outHospitalEndDate"  value='${endTime }' onFocus="WdatePicker()" type="text" >
               </li>
               <li class="Label_1" style="width:11%">ID号：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  id="mrId" value='${medicalSearchVO.mrId }' />
               </li>
               <li class="Label_1" style="width:11%">住院次数：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  id="visitNumber" value='' />
               </li>
               <li class="Label_1" style="width:11%">身份证号：&nbsp;</li>
               <li class="Label_2" style="width:27%;"><input class="input_box" type="text" id="idCard"  value='${medicalSearchVO.idCard }' />          	 
               </li>
               <li class="Label_1" style="width:11%">出院科室：&nbsp;</li>
               <li class="Label_2" >      
               	<select class="input_box" id="outHospitalOfficeId">
               		<option value="">请选择</option>
               		<c:forEach var="office" items="${officeList }"> 
            
               			
               			<c:choose>
							<c:when test="${medicalSearchVO.outHospitalOfficeId == office.id }">
										<option selected="selected" value="${office.id }">${office.name}</option>
									</c:when>
									<c:otherwise>
										<option value="${office.id }">${office.name}</option>
									</c:otherwise>
								</c:choose>
               			
               		</c:forEach>
                	
                	</select>
                </li>
                <li class="Label_1" style="width:11%">姓名：&nbsp;</li>
                <li class="Label_2"><input class="input_box" type="text" id="name"  value='' />          	 
              <!--   <li class="Label_1" style="width:11%;height:78px;line-height:78px;">离院方式：&nbsp;</li>
                <li class="Label_2" style="width:89%;height:78px;padding-top:10px;text-align:left;"> -->
            
                	<%-- <c:forEach items="${outHospitalTypeList}" var="outHospitalType">
                		<input type="checkbox" class="check_cl" name="outHospitalType" value="${outHospitalType.id}"><span>${outHospitalType.name}</span>   		
                	</c:forEach>
                	<input class="btn_qx" type="button"  name='' onclick="selectAll()" value='全选' />
     				<input class="btn_qx" type="button"  name='' id='' onclick="disableAll()" value='取消' /> --%>
                	
                </li> 
                    <li class="Label_5">
                        <div class="right" style="text-align:right">
                            <a id="Add" onclick="init(1,10)">查询</a>
                        </div>
                    </li>
                </ul>
            </div> 
             <table class="Search_tableList" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="tdLabel_4">ID号</td>
                    <td class="tdLabel_4">姓名</td>
                  
                    <td class="tdLabel_4">证件号码</td>
                    <td class="tdLabel_4">出院科室</td>
                    <td class="tdLabel_4">出院日期</td>
                      <td class="tdLabel_4">住院次数</td>
             <!--        <td class="tdLabel_4">离院方式</td> -->
                    <td class="tdLabel_4">操作</td>
                </tr>
                <tr id="loading" style="height:50px;display:none">
	             	<td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	            </tr>
                <tbody id="tbody">
                
                </tbody>
   
            </table>
        </div>
        <div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
        </div>
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>
<!--JS部分-->

<script>

$("#mrId").change(function(){
	var $this=$(this);
	var inentity=$this.val();
	if(inentity!=null && inentity!='' && inentity!=undefined){
		if(isContainMark(inentity)){
			var mrId=inentity.split("-")[0];
			var visitNumber=inentity.split("-")[1];
			//alert(mrId+"--"+visitNumber);
			$("#mrId").val("").val(mrId);
			$("#visitNumber").val("").val(visitNumber);
			init(1,10);
		}
	}
});

function isContainMark(inentity){
	var reg = RegExp(/-/);
	return reg.test(inentity);
}


   
    $(function(){
    	$("#mrId").focus();
    	var qualityStatus=$("#qualityStatus").val();
    	
    	//alert(qualityStatus);
    	if(qualityStatus){
    		init(1,10);
    	}
	   
   });
    
    
    function init(pageNo,pageSize){
    	 
    	var visitNumber=$("#visitNumber").val();
    	var  name=$("#name").val();
    	var idCard=$("#idCard").val();
    	var  outHospitalStartDate=$("#outHospitalStartDate").val();
    	var  outHospitalEndDate=$("#outHospitalEndDate").val();
    	var  mrId=$("#mrId").val();
    	var  outHospitalOfficeId=$("#outHospitalOfficeId").val();
		/* var outHospitalTypeIds=[];
		outHospitalTypeIds=getFormVals("outHospitalType"); */
		if((visitNumber==null||visitNumber=="")&&(name==null||name=="")&&(idCard==""||idCard==null)&&(mrId==""||mrId==null)&&
				(outHospitalOfficeId==""||outHospitalOfficeId==null)&&(outHospitalStartDate==""||outHospitalStartDate==null)&&(outHospitalEndDate==""||outHospitalEndDate==null)
				){
			layer.alert('请至少输入一个查询条件!', {icon: 0});
			return;
		}
    	jQuery.support.cors = true;
    	$.ajax({
    		type:'get',
    		//url:"${corePath}/medrecord/ajaxPigeonholed",
    		url:"${corePath}/statis/qualityEvaluationPageAjax",
    		data:{visitNumber:visitNumber,name:name,idCard:idCard,outHospitalStartDate:outHospitalStartDate,outHospitalEndDate:outHospitalEndDate,mrId:mrId,outHospitalOfficeId:outHospitalOfficeId,
    			currentPage:pageNo,pageSize:pageSize
    			 },
    		beforeSend:function(){
    	 		$("#tbody").html("");
    	 		$("#loading").show();
    	 	},
    		success:function(data){
    			    console.log(data);
    			    $("#loading").hide();
    			    if(data.success){
    				var hospitalNotes=data.data.hospitalNotesJson;
    				var len=hospitalNotes.length;
    				if(len>0){
    					var totalCounts=data.data.medRecordQuery.totalCounts;
    					
    					page(pageNo,totalCounts);
    					var html='';
        				for(var i=0;i<len;i++){
        					var obj=hospitalNotes[i];
        					html+="<tr>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.mr_id==undefined?'':obj.mr_id)+"</td>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.patient_name==undefined?'':obj.patient_name)+"</td>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.id_number==undefined?'':obj.id_number)+"</td>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.office_name==undefined?'':obj.office_name)+"</td>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.out_hospital_date==undefined?'':obj.out_hospital_date)+"</td>"+
    	    	                  "  <td class='tdLabel_5'>"+(obj.visit_number==undefined?'':obj.visit_number)+"</td>"+
    	    	                  "  <td class='tdLabel_5'> <a class='int'   guid='"+obj.firstGuid+"'   onclick='qualityCont(this)'>质控评分</a></td>"+
    	    	                  "</tr>";
        					
        				}
        				$("#tbody").html("").html(html);
    				}else{
    					layer.alert('查询数据为空!', {icon: 5});
    				    $("#tbody").html("");
                        $("#currentPage").html("0/0");
    					$("#totalPage").html("0");
    					$("#page_plus").html("");
    				}

    			}else{
    				layer.alert(data.msg, {icon: 5});
				    $("#tbody").html("");
                    $("#currentPage").html("0/0");
					$("#totalPage").html("0");
					$("#page_plus").html(""); 
    			}
    		},
    		error:function(data){
    			 $("#loading").hide();
    			 layer.alert("服务器错误", {icon: 5});
    		}
    	})
    }
    
    //病案质控
    function qualityCont(obj){
    	
    	var onlyId=$("#onlyId").val();
    	var  name=$("#name").val();
    	var idCard=$("#idCard").val();
    	var  outHospitalStartDate=$("#outHospitalStartDate").val();
    	var  outHospitalEndDate=$("#outHospitalEndDate").val();
    	var  mrId=$("#mrId").val();
    	var  outHospitalOfficeId=$("#outHospitalOfficeId").val();
    	
    	
    	var $this=$(obj);
    	var firstGuid=$this.attr("guid");
    	window.location.href="${basePath}/quality/detailControl?firstGuid="+firstGuid+"&onlyId="+onlyId+"&name="+encodeURI(encodeURI(name))+"&idCard="+idCard+"&outHospitalStartDate="+outHospitalStartDate+"&outHospitalEndDate="+outHospitalEndDate+"&mrId="+mrId+"&outHospitalOfficeId="+outHospitalOfficeId+"";
    }
    
    //病案质控
    function qualityCont1(obj){
    	
    	var onlyId=$("#onlyId").val();
    	var  name=$("#name").val();
    	var idCard=$("#idCard").val();
    	var  outHospitalStartDate=$("#outHospitalStartDate").val();
    	var  outHospitalEndDate=$("#outHospitalEndDate").val();
    	var  mrId=$("#mrId").val();
    	var  outHospitalOfficeId=$("#outHospitalOfficeId").val();
    	
    	
    	var $this=$(obj);
    	var firstGuid=$this.attr("guid");
    	window.location.href="${basePath}/quality/detailControl1?firstGuid="+firstGuid+"&onlyId="+onlyId+"&name="+encodeURI(encodeURI(name))+"&idCard="+idCard+"&outHospitalStartDate="+outHospitalStartDate+"&outHospitalEndDate="+outHospitalEndDate+"&mrId="+mrId+"&outHospitalOfficeId="+outHospitalOfficeId+"";
    }
    
    
    function searchPic(obj){
    	var $this=$(obj);
    	var firstGuid=$this.attr("guid");
    	
    	window.open("${corePath}/medrecord/paginationMedrecordImages?firstGuid="+firstGuid+"");
    }
    
    function page(currentPage,totalCounts){
    	
        var pageSize = 10;
        var visiblePages = 5;
        var totalPages = Math.ceil(totalCounts/pageSize);
        $('#page_plus').jqPaginator({

            totalCounts: totalCounts,
            pageSize:pageSize,
            visiblePages: visiblePages,
            currentPage: currentPage,

            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num,type) {
            	 
            	 if(type !='init'){
                 
            		 init(num,pageSize);
                 }
            	
                $("#totalPage").html(totalCounts);
                $("#currentPage").html(num+"/"+totalPages);
            }
        });

    }
    
    
	//获取checkbox值
  	 function getFormVals(name){
  			var arr = [];
  			$("input[type='checkbox'][name='"+name+"']:checked").each(function(){
  				arr.push($(this).val());	

  			});
  			return arr.toString();
  	}
	
  	function selectAll(){
  	  $('input[name="outHospitalType"]').each(function(){  
            //此处如果用attr，会出现第三次失效的情况  
            $(this).prop("checked",true);  
        });  
  }

  function disableAll(){
  	  $('input[name="outHospitalType"]').each(function(){  
            //此处如果用attr，会出现第三次失效的情况  
            $(this).prop("checked",false);  
        });  
  }

</script>
</body>
</html>